//
//  TeachCell.m
//  ZhiBoYuan
//
//  Created by apple on 2018/4/19.
//  Copyright © 2018年 apple. All rights reserved.
//

#import "TeachCell.h"
#import "UIButton+LZCategory.h"

@implementation TeachCell

- (void)awakeFromNib {
    [super awakeFromNib];
    // Initialization code
    
//    [_aButton setImage:[UIImage imageNamed:@"课程"] forState:UIControlStateNormal];
//    
//    [_aButton setTintColor:ZhuTiColor];
//
//    [_bButton setImage:[UIImage imageNamed:@"未标题-9-1"] forState:UIControlStateNormal];
//    
//    [_bButton setTintColor:ZhuTiColor];
//
//    [_cButton setImage:[UIImage imageNamed:@"发布"] forState:UIControlStateNormal];
//    
//    [_cButton setTintColor:ZhuTiColor];
//
//    [_dButton setImage:[UIImage imageNamed:@"编辑"] forState:UIControlStateNormal];
//    
//    [_dButton setTintColor:ZhuTiColor];
//
//    [_eButton setImage:[UIImage imageNamed:@"删除-4"] forState:UIControlStateNormal];
//    
//    [_eButton setTintColor:ZhuTiColor];
    
    
}

- (void)setTask:(Task *)task {
    
    _task = task;
    
    if ([task.status integerValue] == 1)
    {
        self.yiFaBu = YES;
    }
    else
    {
        self.yiFaBu = NO;
    }
    
    
    self.banJiLable.text = task.class_list;
    self.tittleLabel.text = task.name;
    self.timeLable.text = task.work_time;
    [self.headImage sd_setImageWithURL:[NSURL URLWithString:task.user_info[@"small_img"]] placeholderImage:[UIImage imageNamed:@""]];
    
    self.headImage.layer.masksToBounds =YES;
    self.headImage.layer.cornerRadius = self.headImage.frame.size.width/2;
    self.nameLabel.text = task.user_info[@"name"];
    self.detailLabel.text = task.detail;
    
    
    
//    NSLog(@"选课= %@ - 选题= %@",task.course_count,task.paper_count);
    
    
    NSString *course = [NSString stringWithFormat:@"  选课 ( %zd )",[task.course_count integerValue]];
    [_aButton setAttributedTitle:[Helper attributedString:course imageName:@"课程" imageFram:CGRectZero]forState:0];

    NSString *paper  = [NSString stringWithFormat:@"  选题 ( %zd )",[task.paper_count integerValue]];
    [_bButton setAttributedTitle:[Helper attributedString:paper imageName:@"课程" imageFram:CGRectZero]forState:0];
    
    NSString *taolun  = [NSString stringWithFormat:@"  发表 ( %zd )",[task.pineLuncount integerValue]];
    [_pingLunButton setAttributedTitle:[Helper attributedString:taolun imageName:@"讨论-2" imageFram:CGRectZero]forState:0];
    
    
    
    
    
    
    
    if (self.yiFaBu == YES)
    {
        [self.bagagrImage setImage:[UIImage imageNamed:@"已发布"]];
        self.buttonTop.constant = 0;
        self.buttonButtom.constant = 0;
        self.bottomButtonHight.constant = 0;
        _bottomLine.backgroundColor = [UIColor clearColor];
        
        [_cButton setAttributedTitle:[Helper attributedString:@" " imageName:@"" imageFram:CGRectZero]forState:0];
        [_dButton setAttributedTitle:[Helper attributedString:@" " imageName:@"" imageFram:CGRectZero]forState:0];
        [_eButton setAttributedTitle:[Helper attributedString:@" " imageName:@"" imageFram:CGRectZero]forState:0];

        _cButton.userInteractionEnabled = NO;
        _dButton.userInteractionEnabled = NO;
        _eButton.userInteractionEnabled = NO;

    }
    else
    {
        self.buttonTop.constant         = 10;
        self.buttonButtom.constant      = 10;
        self.bottomButtonHight.constant = 25;
        [self.bagagrImage setImage:[UIImage imageNamed:@"未发布"]];
        _bottomLine.backgroundColor = hui1Color;

        [_cButton setAttributedTitle:[Helper attributedString:@" 发布" imageName:@"发布" imageFram:CGRectZero]forState:0];
        [_dButton setAttributedTitle:[Helper attributedString:@" 编辑" imageName:@"编辑" imageFram:CGRectZero]forState:0];
        [_eButton setAttributedTitle:[Helper attributedString:@" 删除" imageName:@"删除-4" imageFram:CGRectZero]forState:0];

        _cButton.userInteractionEnabled = YES;
        _dButton.userInteractionEnabled = YES;
        _eButton.userInteractionEnabled = YES;

    }
}



- (void)setSelected:(BOOL)selected animated:(BOOL)animated {
    [super setSelected:selected animated:animated];

    // Configure the view for the selected state
}

@end
